using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Webadmin_Modules_Contact_UserControls_Edit : System.Web.UI.UserControl
{
    //----------------------------------------------------------
    public DataRow _SiteOption = null;
    public DataRow _AdminLang = null;
    public string _Act = "";
    private string _SiteNote = "General";
    private string _LangNote = "Contact";
    public string _Filter = "";
    public string _Navigator = "";
    public string _ID = "";
    private void initSiteLang()
    {
        
        if (!Request.Url.AbsoluteUri.Contains(Session["Page"].ToString()))
        {
            Session["Page"] = Request.Url.AbsoluteUri.Split('?')[0];
        }
        //---------
        Session["Lang"] = Request.QueryString["Lang"] == null ? Session["Lang"] : Request.QueryString["Lang"];
        Session["Lang"] = bzAdminLang.checkLang(Session["Lang"].ToString());
        _SiteOption = new bzSiteOption("SiteAdmin", _SiteNote).SiteOption;
        _AdminLang = new bzAdminLang(Session["Lang"].ToString(), _LangNote).AdminLang;

        this.check(bzCheckAdminUser.Type);
        _Act = Request.QueryString["Act"] == null ? "" : Request.QueryString["Act"];
        _ID = Request.QueryString["ID"] == null ? "-1" : Request.QueryString["ID"];
        this.loadAction();
    }
    private bool check(int Per)
    {
        if (bzCheckAdminUser.checkUserPermission(Session["AdminUser"].ToString(), Session["AdminLevel"].ToString(), Session["IP"].ToString(), Session["LoginID"].ToString(), Session["GroupUser"].ToString(), Session["Page"].ToString(), Per)) return true;
        Response.Redirect(bzStringClass.AlertPermission);
        return false;
    }
    //----------------------------------------------------------------------------------



    private DataTable _dt = new DataTable();
    private bzContact bz = new bzContact();

    protected void Page_Load(object sender, EventArgs e)
    {
        this.initSiteLang();
    }
    private void loadAction()
    {
        if (!IsPostBack)
        {
            switch (_Act)
            {
                case "Edit": this.loadEdit(); break;
            }
        }
    }
    TextBox txtFax = new TextBox();
    TextBox txtSubject = new TextBox();
    TextBox txtCompany = new TextBox();
    private void loadEdit()
    {
        bz.updateRecord(_ID, "0");

        _Navigator = _AdminLang["MenuContact"].ToString() + _AdminLang["GeneralArrow"].ToString() + _AdminLang["MenuContactList"].ToString() + _AdminLang["GeneralArrow"].ToString() + _AdminLang["Edit"].ToString();
       
        _dt = bz.getRecord(_ID,"-1");
        DataRow dr = _dt.Rows[0];
        this.txtNameFull.Text = dr["NameFull"].ToString();
        this.txtCompany.Text = dr["Company"].ToString();
        this.txtAddress.Text = dr["Address"].ToString();
        this.txtPhone.Text = dr["Phone"].ToString();
        this.txtFax.Text = dr["Fax"].ToString();
        this.txtEmail.Text = dr["Email"].ToString();
        this.txtSubject.Text = dr["Subject"].ToString();
        this.txtContent.Text = Server.HtmlDecode(dr["Content"].ToString());
        this.txtPostedDate.Text = bzStringClass.getStringDate(dr["PostedDate"], Session["Lang"].ToString());
    }
    
}
